﻿#region Declaration

//------------------------------------------------------------------------------
// Compas Information Techonoly Co., Ltd
// The Initial Developer of the Original Code is CompasSolutions.
// All Rights Reserved.
// 
// Contributor(s): _______. 
//------------------------------------------------------------------------------

#endregion

#region Using Directives

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Globalization;
using QuickDev.Common.Utils;

#endregion

namespace QuickDev.Common.Globalization
{
    public class CultureComparer : IComparer
    {
        #region IComparer Members

        /// <summary>
        /// Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
        /// </summary>
        /// <param name="x">The first object to compare.</param>
        /// <param name="y">The second object to compare.</param>
        /// <returns>
        /// Value Condition Less than zero x is less than y. Zero x equals y. Greater than zero x is greater than y.
        /// </returns>
        /// <exception cref="T:System.ArgumentException">Neither x nor y implements the <see cref="T:System.IComparable"></see> interface.-or- x and y are of different types and neither one can handle comparisons with the other. </exception>
        public int Compare( object x , object y )
        {
            Validation.ValidateObjectType( x , typeof( CultureInfo ) );
            Validation.ValidateObjectType( y , typeof( CultureInfo ) );

            CultureInfo a = x as CultureInfo;
            CultureInfo b = y as CultureInfo;

            return a.DisplayName.CompareTo( b.DisplayName );
        }

        #endregion
    }
}
